//
//  SISSEscrowUnfreezeShowViewController.m
//  SISSAPP
//
//  Created by 袁应荣 on 2018/10/26.
//  Copyright © 2018年 优房网. All rights reserved.
//

#import "SISSEscrowUnfreezeShowViewController.h"
#import "SISSEscrowUnfreezeFillInViewController.h"
#import "SISSNetworkingManager+HouseProgress.h"
#import "SISSHouseProgressViewController.h"
#import "SISSPassengerProgressViewController.h"

@interface SISSEscrowUnfreezeShowViewController ()

@property (strong, nonatomic) SISSEscrowTrawInfoModel *escrowTrawInfoModel;

@end

@implementation SISSEscrowUnfreezeShowViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"监管解冻";
    self.tipStr = @"资金划转条件";
    self.bottomButtonStr = @"录入解冻信息";
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back"] style:UIBarButtonItemStylePlain target:self action:@selector(backItemAction)];
    [self requestData];
}

/**
 返回按钮点击事件
 */
- (void)backItemAction {
    
    for (UIViewController *controller in self.navigationController.viewControllers) {
        if ([controller isKindOfClass:[SISSHouseProgressViewController class]] || [controller isKindOfClass:[SISSPassengerProgressViewController class]]) {
            [self.navigationController popToViewController:controller animated:YES];
        }
    }
}

- (void)requestData {
    NSString *ahbpId = self.houseProgressModel ? self.houseProgressModel.ahbpId : self.passengerProgressRecordInfoModel.ahbpId;
    [kNetworkManager requestEscrowTrawnInfoWithAhbpId:ahbpId success:^(SISSEscrowTrawInfoModel *escrowTrawInfoModel) {
        NSString *text = [NSString stringWithFormat:@" 根据买卖双方签订的资金监管协议，资金监管方已经监管解冻。\n解冻时间：%@\n解冻方式：%@\n短期利息：%@",[NSDate yyr_stringToString:escrowTrawInfoModel.thawTime],escrowTrawInfoModel.thawWay,escrowTrawInfoModel.interestProcess];
        self.textStr = text;
        self.escrowTrawInfoModel = escrowTrawInfoModel;
        if (self.isHistory && !escrowTrawInfoModel) {
            self.tipStr = @"";
            self.textStr = @"";
            self.bottomButtonStr = @"";
        }
    } failed:^(NSError *error) {
        NSLog(@"%@",error);
    }];
}

/**
 开始按钮点击事件
 */
- (void)startButtonClickAction {
    
    SISSEscrowUnfreezeFillInViewController *vc = [[SISSEscrowUnfreezeFillInViewController alloc] init];
    vc.houseProgressModel = self.houseProgressModel;
    vc.houseProgressRecordInfoModel = self.houseProgressRecordInfoModel;
    vc.passengerProgressModel = self.passengerProgressModel;
    vc.passengerProgressRecordInfoModel = self.passengerProgressRecordInfoModel;
    vc.escrowTrawInfoModel = self.escrowTrawInfoModel;
    [self.navigationController pushViewController:vc animated:YES];
}


@end
